//
//  reserveView.m
//  SimpleHappy
//
//  Created by lanou on 15/11/26.
//  Copyright © 2015年 RockyFung. All rights reserved.
//

#import "reserveView.h"
#import "Define.h"
#import "CollectionViewCell.h"
#import "FoodTableViewController.h"
#import "PlayTableViewController.h"
#import "LiveTableViewController.h"
@interface reserveView ()<UICollectionViewDataSource,UICollectionViewDelegate,UICollectionViewDelegateFlowLayout>


@property(nonatomic,assign)NSInteger number;
@end
@implementation reserveView

- (id)initWithFrame:(CGRect)frame kindOfNumber:(NSInteger)number  array:(NSArray *)array
{
    CGFloat height = 40*KScreenWidth/375;
    self = [super initWithFrame:frame];
    if (self)
    {
        self.array =array;
        self.number = number;
        UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc]init];
        self.kindCollectionView = [[UICollectionView alloc]initWithFrame:CGRectMake(0, 0, KScreenWidth, height) collectionViewLayout:layout];
        self.kindCollectionView.delegate = self;
        self.kindCollectionView.dataSource = self;
        layout.itemSize = CGSizeMake(KScreenWidth/number, height);
        layout.minimumInteritemSpacing = 0;
        layout.minimumLineSpacing = 0;
        [self.kindCollectionView registerClass:[CollectionViewCell class] forCellWithReuseIdentifier:@"cell"];
        self.kindCollectionView.backgroundColor = [UIColor whiteColor];
        [self addSubview:_kindCollectionView];
        self.scrollView = [[UIScrollView alloc]initWithFrame:CGRectMake(0, height, KScreenWidth, KScreenHeight - height)];
        [self addSubview:self.scrollView];
        self.scrollView.contentSize = CGSizeMake(KScreenWidth*number, KScreenHeight-height);
        [self.scrollView setContentOffset:CGPointMake(0, 0)];
        self.scrollView.pagingEnabled = YES;
        self.scrollView.bounces=NO;
    }
    return self;
}
-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
    return self.number;
}
-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    CollectionViewCell *cell = [self.kindCollectionView dequeueReusableCellWithReuseIdentifier:@"cell" forIndexPath:indexPath];
    cell.label.text = self.array[indexPath.row];
    return cell;
}

@end
